package tests;

import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;

import org.joda.time.LocalDate;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import data.enums.Classification;
import data.enums.Index;
import data.input.Data;
import entities.IndexTuple;

public class YahooCsvTests {

	private static Data data;

	@BeforeClass
	public static void setUpBeforeClass() throws IOException, ParseException {
		data = Data.createData(Index.BSE_Sensex);
	}
	
	@Before
	public void setUp() throws Exception {}

	@Test
	public void testLastTuple() throws IOException, ParseException {

		LocalDate date = new LocalDate(2012, 4, 4);

		IndexTuple tuple = data.getIndexTuple(date);
		IndexTuple artificialTuple = new IndexTuple(date, new BigDecimal("17486.02"), Classification.LOW);

		assertEquals(tuple, artificialTuple);

	}

	//UNDEFINED DOES NOT EXIST ANYMORE
//	@Test
//	public void testFirstTuple() {
//
//		LocalDate date = new LocalDate(2005, 6, 1);
//
//		Tuple tuple = data.getTuple(date);
//		Tuple artificialTuple = new Tuple(date, new BigDecimal("6729.90"), Classification.UNDEFINED);
//		
//		assertEquals(tuple, artificialTuple);
//
//	}
	
	@Test
	public void testMiddleTuple() {

		LocalDate date = new LocalDate(2005, 6, 14);

		IndexTuple tuple = data.getIndexTuple(date);
		IndexTuple artificialTuple = new IndexTuple(date, new BigDecimal("6860.18"), Classification.HIGH);

		assertEquals(tuple, artificialTuple);

	}
	
	@After
	public void tearDown() throws Exception {}
	
	@AfterClass
	public static void tearDownAfterClass() throws Exception {}

}